﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLFacade.entities;
using BLFacade;

namespace ProjectUI
{
    public partial class CustomerListForm : Form
    {

        public CustomerListForm()
        {
            InitializeComponent();
            gridViewCustomers.DataSource = FacadeHolder.DataFacade.GetCustomers();
            this.Text = "All customers";
        }

        private void gridViewContacts_DoubleClick(object sender, EventArgs e)
        {
            int index = gridViewCustomers.SelectedCells[0].RowIndex;
            CustomerForm info = new CustomerForm(((List<ICustomer>)gridViewCustomers.DataSource)[index]);
            info.MdiParent = this.MdiParent;
            info.Show();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            CustomerForm info = new CustomerForm();
            info.MdiParent = this.MdiParent;
            info.Show();
            this.Close();
        }

        //public void UpdateDataSource()
        //{
        //    gridViewCustomers.DataSource = FacadeHolder.DataFacade.GetCustomers();
        //}
    }
}
